#include <stdio.h>
typedef struct
{
    int r, g, b;
} Color;

Color color[16];

int main()
{
    Color c;
    int i;
    int min_dis, dis, index;
    for (i = 0; i < 16; i++)
        scanf("%d%d%d", &color[i].r, &color[i].g, &color[i].b);
    while (1)
    {
        scanf("%d%d%d", &c.r, &c.g, &c.b);
        min_dis = 10000000;
        if (c.r == -1 && c.g == -1 && c.b == -1)
            break;
        for (i = 0; i < 16; i++)
        {
            dis = (color[i].r - c.r) * (color[i].r - c.r) + (color[i].g - c.g) * (color[i].g - c.g) + (color[i].b - c.b) * (color[i].b - c.b);
            if (dis < min_dis)
            {
                min_dis = dis;
                index = i;
            }
        }
        printf("(%d,%d,%d) maps to (%d,%d,%d)\n", c.r, c.g, c.b, color[index].r, color[index].g, color[index].b);
    }
    return 0;
}